﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;

namespace QLThuVien
{
    class LopTimKiem
    {
        public LopTimKiem(){}

        public DataSet chuoinhaplieu(string strtk)
        {
            Truyxuatdulieu dl = new Truyxuatdulieu();
            return dl.getdata("select sach.masach as ' Mã Sách',sach.tensach as 'tên sách',tacgia.HOTEN as 'Tên tác giả',ngonngu.NGONNGU as 'Ngôn ngữ',vitriluutru.ke as 'Kệ',vitriluutru.ngan as 'Ngăn' from tacgia,loaisach,ngonngu,sach,vitriluutru where sach.maloai = loaisach.maloai and tacgia.matacgia = sach.matacgia and sach.mann = ngonngu.mann and (sach.tensach like N'%" + strtk + "%' or tacgia.HOTEN like N'%" + strtk + "%' or sach.masach='" + strtk + "')");

        }
          
        public DataSet theodanhmuc(string strsach, string tacgia, string strloaisach, string strngonngu,string strnxb,string strncc)
        {
            string strkn = "select SACH.MASACH as ' Mã Sách',SACH.TENSACH as 'Tên Sách',TACGIA.HOTEN as 'Tên tác giả',NXB.TENNXB as 'Nhà Xuất bản',NHACUNGCAP.TENNCC AS 'Nhà Cung Cấp' ,NGONNGU.NGONNGU as 'Ngôn ngữ' from SACH,LOAISACH,NHACUNGCAP,NGONNGU,NXB,TACGIA,SANGTAC WHERE SACH.MANGONNGU=NGONNGU.MANGONNGU AND SACH.MALOAISACH=LOAISACH.MALOAISACH AND SACH.MANXB=NXB.MANXB AND SACH.MASACH=SANGTAC.MASACH AND SACH.MANCC=NHACUNGCAP.MANCC AND TACGIA.MATACGIA=SANGTAC.MATACGIA AND SACH.TENSACH like N'%" + strsach + "%' ";
            if (tacgia != "") strkn = strkn + " and tacgia.HOTEN like N'%" + tacgia + "%'";
            if (strloaisach != "") strkn = strkn + " and loaisach.TENLOAISACH like N'%" + strloaisach + "%'";
            if (strngonngu != "") strkn = strkn + " and ngonngu.NGONNGU like N'%" + strngonngu + "%'";
            if (strnxb != "") strkn = strkn + "and NXB.TENNXB like N'%" + strnxb + "%'";
            if(strncc !="") strncc=strkn+"AND NHACUNGCAP.TENNCC like N'%"+ strncc + "%'";
            Truyxuatdulieu dl = new Truyxuatdulieu();
            return dl.getdata(strkn);
        }
    }
}
